<template>
  <div id="tabcontrol">
    <div v-for="(item,index) in titles" :key="index" class="con-items" :class="{active:index === currentIndex}" @click="itemClick(index)">
      {{item}}
    </div>
  </div>
</template>

<script>
export default {
  name: 'TabControl',
  props:{
    titles:{
      type: Array,
      default(){
        return []
      }
    }
  },
  data(){
    return{
      currentIndex:0
    }
  },
  methods:{
    itemClick(index){
      this.currentIndex = index;
      this.$emit('tabClick', index)
    }
  }
}
</script>
  
<style >
  #tabcontrol{
    display: flex;
    text-align: center;
    background: rgba(255, 255, 255, 0.945);
  }
  .con-items{
    flex: 1;
    text-align: center;
    font-size: 15px;
    margin: 5px 42px;
    height: 30px;
    line-height: 30px;
  }

  .active{
    color: MediumBlue;
    border-bottom: 3px solid mediumblue;
  }
</style>